package org.example.cloudapply.repository;

import org.apache.ibatis.annotations.*;
import org.example.cloudapply.entity.CloudType;
import org.example.cloudapply.entity.InstanceTemplate;

import java.awt.print.Pageable;
import java.util.List;

@Mapper
public interface TemplateRepository {
    @Select("SELECT * FROM instance_templates WHERE cloud_type = #{cloudType}")
    List<InstanceTemplate> findByCloudType(CloudType cloudType);

    @Insert("INSERT INTO instance_templates (cloud_type, cpu_cores, memory_gb, gpu_supported) " +
            "VALUES (#{cloudType}, #{cpuCores}, #{memoryGb}, #{gpuSupported})")
    @Options(useGeneratedKeys = true, keyProperty = "templateId")
    int insert(InstanceTemplate template);

    @Delete("DELETE FROM instance_templates WHERE template_id = #{templateId}")
    int deleteById(Integer templateId);

    @Select("SELECT * FROM instance_templates")
    List<InstanceTemplate> findAll();


}